package my.headfirstjava.templatemethod.barista;

public abstract class CaffeineBeverageWithHook {

	//准备制作
	final void prepareRecipe() {
		//烧开水
		boilWater();
		//冲泡
		brew();
		//将饮料倒入杯子中
		pourInCup();
		//用户想加调料(钩子 改变执行流程的)
		if (customerWantsCondiments()) {
			//添加调料
			addCondiments();
		}
	}
 
	abstract void brew();
 
	abstract void addCondiments();
 
	void boilWater() {
		System.out.println("Boiling water");
	}
 
	void pourInCup() {
		System.out.println("Pouring into cup");
	}
 
	boolean customerWantsCondiments() {
		return true;
	}
}
